﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Entity;
using BO;

namespace Final_Prototype_UsingDev_QuanLy_071012
{
    public partial class Form_Contact : Form
    {
        private readonly Form_Custom_Management_Add _frAdd;
        ContactBO cBO = new ContactBO();
        ContactEntity cEntity = new ContactEntity();
        public Form_Contact(Form_Custom_Management_Add frAdd)
        {
            InitializeComponent();
            _frAdd = frAdd;
        }

        private void AddContact()
        {
 
            cEntity.ContactPerson = txtContactPerson.Text;
            cEntity.Address = rtbAddress.Text;
            cEntity.Tel  =txtTel.Text;
            cEntity.Email = txtEmail.Text;
            cEntity.Remark = rtbRemark.Text;

 
                        
        }

        private void txtContactPerson_TextChanged(object sender, EventArgs e)
        {
            if (txtContactPerson.Text == "")
            {

                lblCheckContactPerson.Visible = true;
                btnAddNewContact.Enabled = false;
            }
            else
            {

                lblCheckContactPerson.Visible = false;
                btnAddNewContact.Enabled = true;
            };
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you want to quit?", "Warning", MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                this.Close();
            }
        }

        private void Form_Contact_Load(object sender, EventArgs e)
        {

        }

        private void btnAddNewContact_Click(object sender, EventArgs e)
        {
            AddContact();
            _frAdd.AddText(txtContactPerson.Text);
            _frAdd._contact = cEntity;
            this.Close();

        }
    }
}
